package com.chinasofti.set;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class MySet1 {
    public static void main(String[] args) {
        Set<String> set = new TreeSet<>();
        //添加元素
        set.add("ccc");
        set.add("aaa");
        set.add("bbb");
        set.add("aaa");

        for (int i=0;i<set.size();i++){
            //System.out.println(set.get(i));
        }

        Iterator<String> it = set.iterator();
        while(it.hasNext()){
            String s = it.next();
            System.out.println("s = " + s);
        }
        for ( String str:set) {
            System.out.println("str = " + str);
        }
    }
}
